<!DOCTYPE html>

<html lang="en">

<head>

    {include file="public/meta" /}

    {include file="public/link" /}

    {include file="public/form" /}

</head>

<body data-type="index" class="theme-white">

<div class="am-g tpl-g">

    {include file="public/header" /}

    {include file="public/left" /}

    {include file="public/content_top" /}

    <ol class="am-breadcrumb" style="    margin-bottom: 0;">

        <li><a href="../home/index.html" class="am-icon-home">首页</a></li>

        <li><a href="#">矿机管理</a></li>

        <!--<li class="am-active">矿机修改</li>-->

    </ol>

    <div class="widget am-cf">

        <form class="am-cf" id="form" onsubmit="return false">

            <div class="am-panel am-panel-primary">

                <div class="am-panel-hd">基础信息</div>

                <div class="am-panel-bd">

                    <input type="hidden" name="id" value="{$list.id}"/>

                    <div class="am-form-group">
                        <span class="s1">矿机类型：</span>
                        <label class="am-form-label">
                            <input type="text" id="name" class="am-form-field am-input-sm" name="name"
                                   value="{$list.name}" placeholder="请添加矿机类型"/>
                        </label>
                    </div>
                    <div class="am-form-group">
                        <span class="s1">矿机价格：</span>
                        <label class="am-form-label">
                            <input type="text" id="price" class="am-form-field am-input-sm" name="price"
                                   value="{$list.price}" placeholder="请输入矿机价格" />
                        </label>
                    </div>
                    <div class="am-form-group">
                        <span class="s1">矿机总产量：</span>
                        <label class="am-form-label">
                            <input type="text" id="yield" class="am-form-field am-input-sm" name="yield"
                                   value="{$list.yield}" placeholder="请输入矿机总产量"/>
                        </label>
                    </div>
                    <div class="am-form-group">
                        <span class="s1">矿机时间：</span>
                        <label class="am-form-label">
                            <input type="text" id="times" class="am-form-field am-input-sm" name="times"
                                   value="{$list.times}" placeholder="请输入矿机运行时间"/>
                        </label>
                    </div>
                    <div class="am-form-group">
                        <span class="s1">矿机天数：</span>
                        <label class="am-form-label">
                            <input type="text" id="timess" class="am-form-field am-input-sm" name="timess"
                                   value="{$list.timess}" placeholder="请输入矿机运行天数"/>
                        </label>
                    </div>
                    <div class="am-form-group">
                        <span class="s1">矿机算力(单位:G)：</span>
                        <label class="am-form-label">
                            <input type="text" id="count" class="am-form-field am-input-sm" name="count"
                                   value="{$list.count}" placeholder="请输入矿机算力"/>
                        </label>
                    </div>

                    <div class="am-form-group" id="no">

                        <span class="s1">矿机图片：</span>

                        <label class="am-form-label">

                            <img id="newPhoto" src="{$list.pic}" style="max-height:200px;"/>

                        </label>

                        <span class="s2" id="uploadPhotoConfirm"></span>

                    </div>

                    <div class="am-form-group">

                        <span class="s1">上传图片：</span>

                        <label class="am-form-label">

                            <input type="button" class="am-btn am-btn-primary" id="upload_button" value="上传图片"/><br/>

                            <input type="hidden" id="newPhotoName" name="pic" value="{$list.pic}"/>

                            <input type="file" style="display:none" name="file">

                        </label>

                        <span class="s2">*请上传格式为.png .jpg .jpeg 的图片必须为<!--1000*668--> PC:510*1920</span>

                    </div>
                    <div class="am-panel-bd" style="padding-bottom: 1rem;margin-left: 13rem">
                        <button type="submit" class="am-btn am-btn-primary am-btn-sm" onclick="sub() ">确定</button>
                        <a href="index.html" class="am-btn am-btn-secondary am-btn-sm">返回</a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

{include file="public/foot" /}
<script type="text/javascript" src="/static/ajaxupload.js"></script>
<script type="text/javascript">
    $(function () {
        var nav = $('.left-sidebar li.sidebar-nav-link');
        nav.removeClass("active");
        nav.eq({$a}).find('ul').show();
        nav.eq({$a}).find('ul li').eq({$b}).find('a').addClass('active');
    });
    function sub() {
        var arr = parseFormJson("#form");
        $.ajax({
            url: "{:url('Millss/modify_play')}",
            data: {arr: arr},
            type: "post",
            success: function (r) {
                /*console.log(r);
                return false;*/
                if (r['code'] == 1) {
                    alert_open(r['msg'])
                }else{
                    alert_msg(r['msg']);
                }
            }
        });
    }
</script>
<script type="text/javascript">
    $(function () {
        var button = $('#upload_button'), interval;
        var confirmDiv = $('#uploadPhotoConfirm');
        var fileType = 'pic', fileNum = 'one';
        new AjaxUpload(button, {
            action: "{:url('Upload/upload')}",
            name: 'file',
            onSubmit: function (file, ext) {
                if (fileType == 'pic') {
                    if (ext && /^(jpg|png|jpeg|gif|JPG)$/.test(ext)) {
                        this.setData({'info': '文件类型为图片'});
                    } else {
                        confirmDiv.text('文件格式错误，请上传格式为.png .jpg .jpeg 的图片');
                        return false;
                    }
                }
                confirmDiv.text('文件上传中');
                if (fileNum == 'one') this.disable();
                interval = window.setInterval(function () {
                    var text = confirmDiv.text();
                    if (text.length < 14) {
                        confirmDiv.text(text + '.');
                    } else {
                        confirmDiv.text('文件上传中');
                    }
                }, 200);
            },
            onComplete: function (file, response) {

                if (response != 'success') {

                    if (response == '2') {

                        confirmDiv.text("文件格式错误，请上传格式为.png .jpg .jpeg 的图片");

                    } else {

                        confirmDiv.text('上传完成');

                        $("#newPhotoName").val("/uploads/" + response);

                        $("#newPhoto").attr("src", "/uploads/" + response);

                        $('#no').show();

                    }

                }

                window.clearInterval(interval);

                this.enable();

                if (response == 'success') alert('上传成功');

            }

        });

    });

</script>

</body>

</html>